home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
allswag.zip
/
MOUSE.SWG
< prev
next >
Wrap
Text File
|
1993-12-08
|
90KB
|
1 lines
SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00012 RODENT MANAGMENT ROUTINES 1 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSLIB.PAS IMPORT 293 {π***************************************************************************π* MouseLib * *π* Release 6.0 - Added demo Program - Please refer to MOUSETST.PAS to *π* see a demo of the mouseLib Unit usage. *π***************************************************************************π}ππUnit Mouse;ππInterfaceππUsesπ Dos;ππConstπ MOUSEinT = $33; {mouse driver interrupt}π LEFTBUTtoN = 1; {bit 0}π RIGHTBUTtoN = 2; {bit 1}π MIDDLEBUTtoN = 4; {bit 2}ππ CURSor_LOCATION_CHANGED = 1; {event mask bits}π LEFT_BUTtoN_PRESSED = 2;π LEFT_BUTtoN_RELEASED = 4;π RIGHT_BUTtoN_PRESSED = 8;π RIGHT_BUTtoN_RELEASED = 16;π MIDDLE_BUTtoN_PRESSED = 32;π MIDDLE_BUTtoN_RELEASED = 64;ππTypeπ mouseType = (twoButton,threeButton,another);π buttonState = (buttonDown,buttonUp);π direction = (moveRight,moveLeft,moveUp,moveDown,noMove);π grCursorType = Recordπ xH,yH : Byte; {x,y Hot Point}π data : Pointer; {cursor look Pointer}π end;ππVarπ mouse_present : Boolean;π mouse_buttons : mouseType;π eventX,eventY,eventButtons : Word; {any event handler should update}π eventhappened : Boolean; {these Vars to use getLastEvent }π XMotions,YMotions : Word; {per 8 pixels}π mouseCursorLevel : Integer;ππ {if > 0 mouse cursor is visiable, otherwise not, containes the levelπ of showMouseCursor/hideMouseCursor}ππConstπ LastMask : Word = 0;π lastHandler : Pointer = Nil;ππ {when changing the interrupt handler temporarily, save BEForE theπ change these to Variables, and restore them when neccessary}ππ lastCursor : grCursorType = (π xH : 0;π yH : 0;π data : nil );ππ {when changing Graphic cursor temporarily, save these values BEForEπ the change, and restore when neccessary}ππConstπ click_Repeat = 10; { Recommended value For waitForRelease timeOut }ππProcedure initMouse; {when replacing mouse mode do that..!}πProcedure showMouseCursor;πProcedure hideMouseCursor;πFunction getMouseX : Word;πFunction getMouseY : Word;πFunction getButton(Button : Byte) : buttonState;πFunction buttonPressed : Boolean;πProcedure setMouseCursor(x,y : Word);πFunction LastXPress(Button : Byte) : Word;πFunction LastYPress(Button : Byte) : Word;πFunction ButtonPresses(Button : Byte) : Word; {from last last check}πFunction LastXRelease(Button : Byte) : Word;πFunction LastYRelease(Button : Byte) : Word;πFunction ButtonReleases(Button : Byte) : Word; {from last last check}πProcedure mouseBox(left,top,right,bottom : Word); {limit mouse rectangle}πProcedure GraphicMouseCursor(xHotPoint,yHotPoint : Byte; dataofs : Pointer);πProcedure HardwareTextCursor(fromLine,toLine : Byte);πProcedure softwareTextCursor(screenMask,cursorMask : Word);πFunction recentXmovement : direction;πFunction recentYmovement : direction;πProcedure setArrowCursor;πProcedure setWatchCursor;πProcedure setUpArrowCursor;πProcedure setLeftArrowCursor;πProcedure setCheckMarkCursor;πProcedure setPointingHandCursor;πProcedure setDiagonalCrossCursor;πProcedure setRectangularCrossCursor;πProcedure setHourGlassCursor;πProcedure setNewWatchCursor;πProcedure setEventHandler(mask : Word; handler : Pointer);πProcedure setDefaultHandler(mask : Word);πProcedure enableLightPenEmulation;πProcedure disableLightPenEmulation;πProcedure defineSensetivity(x,y : Word);πProcedure setHideCursorBox(left,top,right,bottom : Word);πProcedure defineDoubleSpeedTreshHold(treshHold : Word);πProcedure disableTreshHold;πProcedure defaultTreshHold;πProcedure setMouseGraph;πProcedure resetMouseGraph;πProcedure waitForRelease(timeOut : Word);πProcedure swapEventHandler(mask : Word; handler : Pointer);π{ return old in lastMask and lastHandler }πFunction getMouseSaveStateSize : Word;π{ get mouse from interrupted Program, and stop it ..}πProcedure interceptMouse;πProcedure restoreMouse;π{π**************************************************************************π* MouseLib * *π* * *π* mouseLib - Release 2 and abo *π* *π* because of quirks in hercules Graphic mode that is not detectab * *π* by the mouse driver we have to know when we initMouse if we wa * *π* to check For Graphic mode or not, if we do we must perForm a *π* setMouseGraph beFore initGraph, to initGraph in Text mode we m * *π* resetMouseGraph beFore.. , if these calling conventions are no * *π* taken we might have problems in hercules cards! *π* * *π* each call to hideMouseCursor must be balanced by a matching call * *π* to showMouseCursor, 2 calls to hideMou.. and only 1 to showM.. *π* will not show the mouse cursor on the screen! *π**************************************************************************π}πππImplementationππConst watchData : Array [0..31] of Word =π ($E007,$C003,$8001,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$8001,$C003,$E007,π $0,$1FF8,$318C,$6186,$4012,$4022,$4042,$718C,$718C,$4062,$4032,π $4002,$6186,$318C,$1FF8,$0);ππConst arrowData : Array [0..31] of Word =π ($FFFF,$8FFF,$8FFF,$87FF,$83FF,$81FF,$80FF,$807F,$803F,$801F,$800F,π $801F,$807F,$887F,$DC3F,$FC3F,π $0,$0,$2000,$3000,$3800,$3C00,$3E00,$3F00,$3F80,$3FC0,π $3FE0,$3E00,$3300,$2300,$0180,$0180);ππConst UpArrowCursor : Array [0..31] of Word =π ($f9ff,$f0ff,$e07f,$e07f,$c03f,$c03f,$801f,$801f,π $f,$f,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,π $0,$600,$f00,$f00,$1f80,$1f80,$3fc0,$3fc0,π $7fe0,$600, $600, $600, $600, $600, $600, $600);ππConst LeftArrowCursor : Array [0..31] of Wordπ = ($fe1f,$f01f,$0, $0, $0, $f01f,$fe1f,$ffff,π $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $c0, $7c0, $7ffe,$7c0, $c0, $0, $0,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst CheckMarkCursor : Array [0..31] of Wordπ = ($fff0,$ffe0,$ffc0,$ff81,$ff03,$607, $f, $1f,π $c03f,$f07f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $6, $c, $18, $30, $60, $70c0,$1d80,π $700, $0, $0, $0, $0, $0, $0, $0);ππConst PointingHandCursor : Array [0..31] of Wordπ = ($e1ff,$e1ff,$e1ff,$e1ff,$e1ff,$e000,$e000,$e000,π $0, $0, $0, $0, $0, $0, $0, $0,π $1e00,$1200,$1200,$1200,$1200,$13ff,$1249,$1249,π $f249,$9001,$9001,$9001,$8001,$8001,$8001,$ffff);ππConst DiagonalcrossCursor : Array [0..31] of Wordπ = ($7e0, $180, $0, $c003,$f00f,$c003,$0, $180,π $7e0, $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $700e,$1c38,$660, $3c0, $660, $1c38,$700e,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst RectangularCrossCursor : Array [0..31] of Wordπ = ($fc3f,$fc3f,$fc3f,$0,$0, $0, $fc3f,$fc3f,π $fc3f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $180, $180, $180, $7ffe,$180, $180, $180,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst HourglassCursor : Array [0..31] of Wordπ = ($0, $0, $0, $0, $8001,$c003,$e007,$f00f,π $e007,$c003,$8001,$0, $0, $0, $0, $ffff,π $0, $7ffe,$6006,$300c,$1818,$c30, $660, $3c0,π $660, $c30, $1998,$33cc,$67e6,$7ffe,$0, $0);ππConst newWatchCursor : Array [0..31] of Wordπ = ( $ffff, $c003, $8001, $0, $0, $0, $0, $0, $0,π $0, $0, $0, $0, $8001, $c003, $ffff, $0, $0,π $1ff8, $2004, $4992, $4022, $4042, $518a, $4782,π $4002, $4992, $4002, $2004, $1ff8, $0, $0 );πππConstπ mouseGraph : Boolean = False; {assume Text mode upon entry}ππTypeπ box = Recordπ left,top,right,bottom : Word;π end; {Do not change field order !!!}ππVarπ hideBox : box;π reg : Registers; {general Registers used}π grMode,π grDrv : Integer; {detect Graphic mode if any}π grCode : Integer; {return initGraph code in here}π interceptX,π interceptY : Word;π{π***************************************************************************π* callMouse * *π* * *π* used to call mouse interrupt With global data reg - used as parameters * *π***************************************************************************π}πProcedure callMouse;πbeginπ intr(MOUSEinT,REG);πend; {callMouse}ππ(******************************************************************************π* initMouse *π* For some reason grCode is assigned a value of -11,($FFF5) in the second time*π* we call initmouse after we allready are in Graphics mode, override.. was *π* born because of that situation. *π******************************************************************************)ππProcedure initMouse;πVarπ overRideDriver : Boolean; { True if we over-ridden stupid driver hercules b}πbeginπ overRideDriver := False;π if (mouseGraph and (mem[0:$449] = 7)) then begin { assume no mda - hercules}π mem[0:$449] := 6;π overRideDriver := True;π end;π {trick stupid mouse driver to know we are in Graphic mode}π With reg doπ beginπ ax:=0; {detect genius mouse}π bx:=0; {be sure what mode we get}π callMouse;π mouse_present := (ax <> 0); {not an iret..}π if ((bx and 2) <> 0) thenπ mouse_buttons := twoButtonπ else if ((bx and 3) <> 0) thenπ mouse_buttons := threeButtonπ elseπ mouse_buttons := another; {unknown to us}π end; {with}π if (overRideDriver) thenπ mem[0:$449] := 7;π {restore the stupid situation}π eventX := 0;π eventButtons := 0;π eventY := 0;π eventhappened := False;π XMotions := 8;π YMotions := 16;π mouseCursorLevel := 0; { not visiable, one show to appear }πend; {initMouse}ππ(******************************************************************************ππ* showMouseCursor *ππ******************************************************************************)ππProcedure showMouseCursor;ππbeginπ reg.ax:=1; {enable cursor display}π callMouse;π inc(mouseCursorLevel);πend; {showMouseCursor}ππ(******************************************************************************ππ* hideMouseCursor *ππ******************************************************************************)ππProcedure hideMouseCursor;ππbeginπ reg.ax:=2; {disable cursor display}π callMouse;π dec(mouseCursorLevel);πend; {hideMouseCursor}ππ(******************************************************************************ππ* getMouseX *ππ******************************************************************************)ππFunction getMouseX : Word;πππbeginπ reg.ax := 3;π callMouse;π getMouseX := reg.cx;πend; {getMouseX}ππ(******************************************************************************ππ* getMouseY *ππ******************************************************************************)ππFunction getMouseY : Word;ππbeginπ reg.ax := 3;π callMouse;π getMouseY := reg.dx;πend; {getMouseX}ππ(******************************************************************************ππ* getButton *ππ******************************************************************************)ππFunction getButton(Button : Byte) : buttonState;ππbeginπ reg.ax := 3;π callMouse;π if ((reg.bx and Button) <> 0) thenπ getButton := buttonDownπ {bit 0 = left, 1 = right, 2 = middle}π else getButton := buttonUp;πend; {getButton}ππ(******************************************************************************ππ* buttonPressed *ππ******************************************************************************)ππFunction buttonPressed : Boolean;ππbeginπ reg.ax := 3;π callMouse;π if ((reg.bx and 7) <> 0) thenπ buttonPressed := Trueπ else buttonPressed := False;πend; {buttonPressed}ππ(******************************************************************************ππ* setMouseCursor *ππ******************************************************************************)ππProcedure setMouseCursor(x,y : Word);ππbeginπ With reg do beginπ ax := 4;π cx := x;π dx := y; {prepare parameters}π callMouse;π end; {with}πend; {setMouseCursor}ππ(******************************************************************************ππ* lastXPress *ππ******************************************************************************)ππFunction lastXPress(Button : Byte) : Word;ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π lastXPress := reg.cx;πend; {lastXpress}ππ(******************************************************************************ππ* lastYPress *ππ******************************************************************************)ππFunction lastYPress(Button : Byte) : Word;ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π lastYPress := reg.dx;πend; {lastYpress}ππ(******************************************************************************ππ* buttonPresses *ππ******************************************************************************)ππFunction buttonPresses(Button : Byte) : Word; {from last check}ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π buttonPresses := reg.bx;πend; {buttonPresses}πππ(******************************************************************************ππ* lastXRelease *ππ******************************************************************************)ππFunction lastXRelease(Button : Byte) : Word;ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π lastXRelease := reg.cx;πend; {lastXRelease}ππ(******************************************************************************ππ* lastYRelease *ππ******************************************************************************)ππFunction lastYRelease(Button : Byte) : Word;ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π lastYRelease := reg.dx;πend; {lastYRelease}ππ(******************************************************************************ππ* buttonReleases *ππ******************************************************************************)ππFunction buttonReleases(Button : Byte) : Word; {from last check}ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π buttonReleases := reg.bx;πend; {buttonReleases}ππ(******************************************************************************ππ* swap *ππ******************************************************************************)ππProcedure swap(Var a,b : Word);ππVar c : Word;ππbeginπ c := a;π a := b;π b := c; {swap a and b}πend; {swap}ππ(******************************************************************************ππ* mouseBox *ππ******************************************************************************)ππProcedure mouseBox(left,top,right,bottom : Word);ππbeginπ if (left > right) then swap(left,right);π if (top > bottom) then swap(top,bottom); {make sure they are ordered}π reg.ax := 7;π reg.cx := left;π reg.dx := right;π callMouse; {set x range}π reg.ax := 8;π reg.cx := top;π reg.dx := bottom;π callMouse; {set y range}πend; {mouseBox}ππ(******************************************************************************ππ* GraphicMouseCursor *ππ******************************************************************************)ππProcedure GraphicMouseCursor(xHotPoint,yHotPoint : Byte; dataofs : Pointer);ππ{define 16*16 cursor mask and screen mask, pointed by data,π dataofs is Pointer to data of the masks.}ππbeginπ reg.ax := 9;π reg.bx := xHotPoint;π reg.cx := yHotPoint;π reg.dx := ofs(dataofs^); {DS:DX point to masks}π reg.es := seg(dataofs^);π callMouse;π lastCursor.xH := xHotPoint;π lastCursor.yH := yHotPoint;π lastCursor.data := dataofs;π {save it in lastCursor, if someone needs to change cursor temporary}πend; {GraphicMouseCursor}ππ(******************************************************************************ππ* HardwareTextCursor *ππ******************************************************************************)ππProcedure HardwareTextCursor(fromLine,toLine : Byte);ππ{set Text cursor to Text, using the scan lines from..to,ππ(Continued to next message)π--- FreeMail 1.07bπ * origin: Meredith Place BBS * Tucson, AZ * 602-579-0869 * (1:300/15)π<<<>>>πππDate: 03-02-93 (20:07) Number: 14561 of 14567 (Echo)π to: ROBERT BAKER Refer#: NONEπFrom: STEVE CONNET Read: NOπSubj: MOUSE 6/10 Status: PUBLIC MESSAGEπConf: F-PASCAL (1221) Read Type: GENERAL (+)ππ(Continued from previous message)ππ same as intr 10 cursor set in bios :π color scan lines 0..7, monochrome 0..13 }ππbeginπ{ reg.ah:=$10;π reg.ch:=fromLine;π reg.cl:=toLine;π}π reg.ax := 10;π reg.bx := 1; {hardware Text}π reg.cx := fromLine;π reg.dx := toLine;π callMouse;πend; {hardwareTextCursor}ππ(******************************************************************************ππ* softwareTextCursor *ππ******************************************************************************)ππProcedure softwareTextCursor(screenMask,cursorMask : Word);ππ{ when in this mode the cursor will be achived by anding the screen Wordπ With the screen mask (Attr,Char in high,low order) andπ xoring the cursor mask, ussually used by putting the screen attrπ we want preserved in screen mask (and 0 into screen mask Characterπ Byte), and Character + attributes we want to set into cursor mask}ππbeginπ reg.ax := 10;π reg.bx := 0; {software cursor}π reg.cx := screenMask;π reg.dx := cursorMask;π callMouse;πend; {softwareMouseCursor}ππ(******************************************************************************ππ* recentXmovement *ππ******************************************************************************)ππFunction recentXmovement : direction;ππ{from recent call to which direction did we move ?}ππVar d : Integer;ππbeginπ reg.ax := 11;π callMouse;π d := reg.cx;π if (d > 0)π then recentXmovement := moveRightπ else if (d < 0)π then recentXmovement := moveLeftπ else recentXmovement := noMove;πend; {recentXmovement}ππ(******************************************************************************ππ* recentYmovement *ππ******************************************************************************)ππFunction recentYmovement : direction;ππ{from recent call to which direction did we move ?}ππVarπ d : Integer;πbeginπ reg.ax := 11;π callMouse;π d := reg.dx;π if (d > 0)π then recentYmovement := moveDownπ else if (d < 0)π then recentYmovement := moveUpπ else recentYmovement := noMove;πend; {recentYmovement}ππ(******************************************************************************ππ* setWatchCursor *ππ******************************************************************************)ππProcedure setWatchCursor;πbeginπ GraphicMouseCursor(0,0,@watchData);πend; {setWatchCursor}ππ(******************************************************************************ππ* setNewWatchCursor *ππ******************************************************************************)ππProcedure setNewWatchCursor;πbeginπ GraphicMouseCursor(0, 0, @newWatchCursor);πend; {setNewWatchCursor}ππ(******************************************************************************ππ* setUpArrowCursor *ππ******************************************************************************)ππProcedure setUpArrowCursor;ππbeginπ GraphicMouseCursor(5, 0, @upArrowCursor);πend; {setUpArrowCursor}ππ(******************************************************************************ππ* setLeftArrowCursor *ππ******************************************************************************)ππProcedure setLeftArrowCursor;πbeginπ GraphicMouseCursor(0, 3, @leftArrowCursor);πend; {setLeftArrowCursor}ππ(******************************************************************************ππ* setCheckMarkCursor *ππ******************************************************************************)ππProcedure setCheckMarkCursor;πbeginπ GraphicMouseCursor(6, 7, @checkMarkCursor);πend; {setCheckMarkCursor}ππ(******************************************************************************ππ* setPointingHandCursor *ππ******************************************************************************)ππProcedure setPointingHandCursor;πbeginπ GraphicMouseCursor(5, 0, @pointingHandCursor);πend; {setPointingHandCursor}ππ(******************************************************************************ππ* setDiagonalCrossCursor *ππ******************************************************************************)ππProcedure setDiagonalCrossCursor;πbeginπ GraphicMouseCursor(7, 4, @diagonalCrossCursor);πend; {setDiagonalCrossCursor}ππ(******************************************************************************ππ* setRectangularCrossCursor *ππ******************************************************************************)ππProcedure setRectangularCrossCursor;πbeginπ GraphicMouseCursor(7, 4, @rectangularCrossCursor);πend; {setRectangularCrossCursor}ππ(******************************************************************************ππ* setHourGlassCursor *ππ******************************************************************************)ππProcedure setHourGlassCursor;πbeginπ GraphicMouseCursor(7, 7, @hourGlassCursor);πend; {setHourGlassCursor}ππ(******************************************************************************ππ* setArrowCursor *ππ******************************************************************************)ππProcedure setArrowCursor;πbeginπ GraphicMouseCursor(1,1,@arrowData);πend; {setArrowCursor}ππ(******************************************************************************ππ* setEventHandler *ππ******************************************************************************)ππProcedure setEventHandler(mask : Word; handler : Pointer);ππ{handler must be a Far interrupt routine }ππbeginπ reg.ax := 12; {set event handler Function in mouse driver}π reg.cx := mask;π reg.es := seg(handler^);π reg.dx := ofs(handler^);π callMouse;π lastMask := mask;π lastHandler := handler;πend; {set event Handler}ππ(******************************************************************************ππ* defaultHandler *ππ******************************************************************************)ππ{$F+} Procedure defaultHandler; Assembler; {$F-}πAsmπ push ds; { save TP mouse driver }π mov ax, SEG @data;π mov ds, ax; { ds = TP:ds, not the driver's ds }π mov eventX, cx; { where in the x region did it occur }π mov eventY, dx;π mov eventButtons, bx;π mov eventHappened, 1; { eventHapppened := True }π pop ds; { restore driver's ds }π ret;πend;ππ{ this is the default event handler , it simulates :ππ beginπ eventX := cx;π eventY := dx;π eventButtons := bx;π eventhappened := True;π end;ππ}ππ(******************************************************************************ππ* GetLastEvent *ππ******************************************************************************)ππFunction GetLastEvent(Var x,y : Word;π Var left_button,right_button,middle_button : buttonState) : Boolean;ππbeginπ getLastEvent := eventhappened; {indicate if any event happened}π eventhappened := False; {clear to next read/event}π x := eventX;π y := eventY;π if ((eventButtons and LEFTBUTtoN) <> 0) thenπ left_button := buttonDownπ else left_button := buttonUp;π if ((eventButtons and RIGHTBUTtoN) <> 0) thenπ right_button := buttonDownπ else right_button := buttonUp;π if ((eventButtons and MIDDLEBUTtoN) <> 0) thenπ middle_button := buttonDownπ else middle_button := buttonUp;πend; {getLastEvent}ππ(******************************************************************************ππ* setDefaultHandler *ππ******************************************************************************)ππProcedure setDefaultHandler;ππ{get only event mask, and set event handler to defaultHandler}ππbeginπ setEventHandler(mask,@defaultHandler);πend; {setDefaultHandler}ππ(******************************************************************************ππ* enableLightPenEmulation *ππ******************************************************************************)ππProcedure enableLightPenEmulation;ππbeginπ reg.ax := 13;π callMouse;πend; {enableLightPenEmulation}ππ(******************************************************************************ππ* disableLightPenEmulation *ππ******************************************************************************)ππProcedure disableLightPenEmulation;ππbeginπ reg.ax := 14;π callMouse;πend; {disableLightPenEmulation}ππ(******************************************************************************ππ* defineSensetivity *ππ******************************************************************************)ππProcedure defineSensetivity(x,y : Word);ππbeginπ reg.ax := 15;π reg.cx := x; {# of mouse motions to horizontal 8 pixels}π reg.dx := y; {# of mouse motions to vertical 8 pixels}π callMouse;π XMotions := x;π YMotions := y; {update global Unit Variables}πend; {defineSensetivity}ππ(******************************************************************************ππ* setHideCursorBox *ππ******************************************************************************)ππProcedure setHideCursorBox(left,top,right,bottom : Word);ππbeginπ reg.ax := 16;π reg.es := seg(HideBox);π reg.dx := ofs(HideBox);π HideBox.left := left;π HideBox.right := right;π HideBox.top := top;π HideBox.bottom := bottom;π callMouse;πend; {setHideCursorBox}ππ(******************************************************************************ππ* defineDoubleSpeedTreshHold *ππ******************************************************************************)ππProcedure defineDoubleSpeedTreshHold(treshHold : Word);ππbeginπ reg.ax := 17;π reg.dx := treshHold;π callMouse;πend; {defineDoubleSpeedTreshHold - from what speed to Double mouse movement}ππ(******************************************************************************ππ* disableTreshHold *ππ******************************************************************************)ππProcedure disableTreshHold;ππbeginπ defineDoubleSpeedTreshHold($7FFF);πend; {disableTreshHold}ππ(******************************************************************************ππ* defaultTreshHold *ππ******************************************************************************)ππProcedure defaultTreshHold;ππbeginπ defineDoubleSpeedTreshHold(64);πend; {defaultTreshHold}ππ(******************************************************************************ππ* setMouseGraph *ππ******************************************************************************)ππProcedure setMouseGraph;ππbeginπ mouseGraph := True;πend; {setMouseGraph}ππ(******************************************************************************ππ* resetMouseGraph *ππ******************************************************************************)ππProcedure resetMouseGraph;ππbeginπ mouseGraph := False;πend; {resetMouseGraph}πππ(******************************************************************************ππ* waitForRelease *ππ* Wait Until button is release, or timeOut 1/100 seconds pass. (might miss a *ππ* tenth (1/10) of a second.ππ******************************************************************************)ππProcedure waitForRelease;πVarπ sHour, sMinute, sSecond, sSec100 : Word; { Time at start }π cHour, cMinute, cSecond, cSec100 : Word; { Current time }π stopSec : longInt;π currentSec : longInt;π Delta : longInt;πbeginπ getTime(sHour, sMinute, sSecond, sSec100);π stopSec := (sHour*36000 + sMinute*600 + sSecond*10 + sSec100 + timeOut) modππ (24*360000);π Repeatπ getTime(cHour, cMinute, cSecond, cSec100);π currentSec := (cHour*36000 + cMinute*600 + cSecond*10 + cSec100);π Delta := currentSec - stopSec;π Until (not ButtonPressed) or (Delta >=0) and (Delta < 36000);πend; {waitForRelease}ππ(******************************************************************************ππ* swapEventHandler *ππ* handler is a Far routine. *ππ******************************************************************************)ππProcedure swapEventHandler;πbeginπ reg.ax := $14;π reg.cx := mask;π reg.es := seg(handler^);π reg.dx := ofs(handler^);π callMouse;π lastMask := reg.cx;π lastHandler := ptr(reg.es,reg.dx);πend; {swapEventHandler}ππ(******************************************************************************ππ* getMouseSaveStateSize *ππ******************************************************************************)ππFunction getMouseSaveStateSize;πbeginπ reg.ax := $15;π callMouse;π getMouseSaveStateSize := reg.bx;πend; {getMouseSaveStateSize}πππ(******************************************************************************ππ* interceptMouse *ππ******************************************************************************)ππProcedure interceptMouse;πbeginπ With reg do beginπ ax := 3;π callMouse; { get place .. }π interceptX := cx;π interceptY := dx;π ax := 31;π callMouse;π end; { disable mouse driver .. }πend; {interceptMouse}ππ(******************************************************************************ππ* restoreMouse *ππ******************************************************************************)ππProcedure restoreMouse;πbeginπ With reg do beginπ ax := 32; { restore mouse driver .. }π callMouse;π ax := 4;π cx := interceptX;π dx := interceptY;π callMouse;π end; { With .. }πend; {restoreMouse}ππVarπ OldExitProc : Pointer;ππ(******************************************************************************ππ* MyExitProc *ππ******************************************************************************)ππ{$f+}Procedure MyExitProc;πbeginπ ExitProc := OldExitProc;π resetMouseGraph;π initMouse;πend; { myExitProc }ππ{ if this Unit is used With a Graphic Unit that is loaded and executed afterπ this Unit in the Uses clause, the mouse initialization will not beπ correct, be sure to call initMouse in your Program start to workπ properly }ππbegin {Unit initialization}π eventX := 0;π eventY := 0;π eventHappened := False; { initialize ... }π initMouse; {detect in global Variables}π setArrowCursor; {start like that in Graphic mode}π OldExitProc := ExitProc;π ExitProc := @MyExitProc;πend. {mouseLib}πππππππππThis is a demonstration of the previous Unit Robert.πππ(******************************************************************************ππ* mouseTest *ππ* This is a simple test Program that shows if the mouse is Functions, andππ* demonstrates basic mouse Programming using the mouseLib Unit.ππ******************************************************************************)ππProgram mouseTest;ππUses mouse,Crt,Graph;ππVarπ grdriver,π grmode,π ErrCode : Integer;ππProcedure Err(Msg: String);πbeginπ Writeln(Msg);πend;ππbeginπ clrScr;π if not (mouse_present) then beginπ { mouse_present was set by the mouseLib initialization code .. }π Write('mouse not installed');π Exit;π end;π Case mouse_buttons ofπ twoButton : WriteLn('MicroSoft mouse Mode');π threeButton : WriteLn('PC mouse Mode');π else WriteLn('UnRecognized mouse mode');π end; {Case}π Writeln('MouseLib demo Program, (c) 1992, Ron Loewy.');π Writeln;π Writeln('Move Cursor, Press Right & Left buttons together to continue');π Writeln(' Press any mouse button by itself to recognize');π Window(10, 7, 70, 20);π hardwareTextCursor(1,13); { "normal" Text cursor }π showMouseCursor; { display the cursor }π Repeatπ if getButton(leftButton) = buttonDown thenπ WriteLn('Left Button Pressed');π if getButton(rightButton) = buttonDown thenπ WriteLn('right Button Pressed');π if getButton(middleButton) = buttonDown thenπ WriteLn('Middle Button Pressed');π Until (getButton(leftButton) = buttonDown) andπ (getButton(RightButton) = buttonDown);π hideMouseCursor; { we hide the cursor }π grDriver := detect;π initGraph(grDriver, grMode, 'D:\TP\BGI');π ErrCode := GraphResult;π if ErrCode <> grOK then Err('ERRor! not initializing:'+GraphErrorMsg(ErrCoππ setMouseGraph; { fix quircks in Herc. Graphic card }π initMouse; { let the mouse sense it is in Graphic mode }π outTextXY(10, 10, 'MouseLib demo Program, (c) 1992, Ron Loewy.');π outTextXY(10, 30, 'Press the Right Button to end');π showMouseCursor; { draw the Graphic default arrow cursor }π Repeat Until getButton(rightButton) = buttonDown;π hideMouseCursor;π closeGraph;πend.π 2 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSPIC1.PAS IMPORT 23 {π> I'm interested in how to change the default mouse cursor toπ> another user defined shape. if you know how to do that, can youπ> please post the source For it? Thanks in advance.π}πππUsesπ Dos, Graph;ππVarπ Regs : Registers;ππTypeπ CursorType = Array[0..31] of Word; { to store the cursor shape }πππ{ define a cursor shape }πConst HourGlass : CursorType =ππ { this specific Constant, when used in the Procedure to change the cursorπ shape will change it to an hourglass shaped cursor. of course you canπ define your own cursor shape to suit your needs.π the comments beside the hex numbers are what it will look like (binary),π they help TREMendOUSLY in designing a cursor shape. }πππ { Screen mask : the 0's will show up as the background colour, the 1'sπ will show whatever is on the screen at that location }ππ ($0001, { 0000000000000001 }π $0001, { 0000000000000001 }π $8003, { 1000000000000011 }π $C7C7, { 1100011111000111 }π $E38F, { 1110001110001111 }π $F11F, { 1111000100011111 }π $F83F, { 1111100000111111 }π $FC7F, { 1111110001111111 }π $F83F, { 1111100000111111 }π $F11F, { 1111000100011111 }π $E38F, { 1110001110001111 }π $C7C7, { 1100011111000111 }π $8003, { 1000000000000011 }π $0001, { 0000000000000001 }π $0001, { 0000000000000001 }π $0000, { 0000000000000000 }ππ { Cursor mask : the 1's will show up as white (or whatever color you haveπ reassigned it to if you have done a SetPalette or SetRGBPalette) }ππ $0000, { 0000000000000000 }π $7FFC, { 0111111111111100 }π $2008, { 0010000000001000 }π $1010, { 0001000000010000 }π $0820, { 0000100000100000 }π $0440, { 0000010001000000 }π $0280, { 0000001010000000 }π $0100, { 0000000100000000 }π $0280, { 0000001010000000 }π $0440, { 0000010001000000 }π $0820, { 0000100000100000 }π $1010, { 0001000000010000 }π $2008, { 0010000000001000 }π $7FFC, { 0111111111111100 }π $0000, { 0000000000000000 }π $0000); { 0000000000000000 }ππProcedure SetMouseCursor(HotX, HotY: Integer; Var Pattern : CursorType);πbeginπ Regs.AX := 9; { Function 9 }π Regs.BX := HotX; { X-ordinate of hot spot }π Regs.CX := HotY; { Y-ordinate of hot spot }π { the hot spots are the co-ordinates that will show up as being whereπ the mouse is when reading the co-ordinates of the mouse }π Regs.DX := ofs(Pattern);π Regs.ES := Seg(Pattern);π Intr($33, Regs);πend;ππbeginπ { [...initialize the Graphics screen etc...] }ππ SetMouseCursor(7, 7, HourGlass);π { this will set the mouse cursor to an hourglass shape With the hot spotπ right in the centre at position 7,7 from the top left of the shape }ππ { [...continue Program...] }πend.π 3 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSPIC2.PAS IMPORT 11 {π>Hey Programmers,π> I'm trying to change the way my mouse cursor looks in one of myπ>Programs from the standard block to an arrow. I looked up the inFormationπ>in my interrupt list and found that I need to use Interrupt 33h (Bigπ>surprise) With AX = 0009h. I'm ok up to this point, but the inFormationπ>lost me when is says that ES:DX->bitmap With 16 Words screen mask and 16π>Words cursor mask. Now I know what it means and have already defined theπ>code For my curse, but how do I assign ES:DX to its value? (Source exampleπ>below). Any help would be great and please E-MAIL it to me. Thanksπ}ππConstπ ArrowCursor: Array [0..31] of Word = (π $3fff,$1fff,$fff,$7ff,$3ff,$1ff,$ff,$7f,π $3f,$1f,$f,$7,$1847,$387f,$fc3f,$fe7f,π $0,$4000,$6000,$7000,$7800,$7c00,$7e00,$7f00,π $7f80,$7fc0,$7fe0,$6730,$4300,$300,$180,$0);π HotSpotX : Word = 1;π HotSpotY : Word = 0;πππProcedure ArrowMouse;πVar regs : Registers;πbeginπ Regs.AX := $000A;π Regs.BX := HotSpotX;π Regs.CX := HotSpotY;ππ { ES:DX -> bitmap 16 Words screen mask 16 Words cusor mask }π Regs.ES := Seg(ArrowCursor); { Answer :) }π Regs.DX := ofs(ArrorCursor); { Answer :) }ππ intr($33,Regs);πend;ππ 4 05-28-9313:52ALL SWAG SUPPORT TEAM RODENT.PAS IMPORT 51 Unit Rodent;πInterfaceπUses Dos;ππconst MDD = $33; { mouse interupt }π { Interupt driven Polled = AX }π bit_0 = $01; { mouse movement left button down }π bit_1 = $02; { left button pressed right button down }π bit_2 = $04; { left button released center button down }π bit_3 = $08; { right button pressed }π bit_4 = $10; { right button released }π bit_5 = $20; { center pressed }π bit_6 = $40; { center released }π bit_7 = $80;ππtypeπ resetRec = recordπ exists : Boolean;π nButtons : Integer;π end;π LocRec = recordπ buttonStatus,π opCount,π column,π row : Integer;π end;π moveRec = recordπ hCount,π vCount : Integer;π end;π{$F+}π eventRec = recordπ flag, button, col, row: Word;π end;π{$F-}ππvar mReg : Registers;π theMouse : resetRec; { Does mouse exist }π mrecord : locRec; { polled record }π mEvent : eventRec; { interupt record }ππprocedure mFixXY (x1,y1,x2,y2:integer);πfunction mouseX (n:integer) : integer;πfunction mouseY (n:integer) : integer;πprocedure mReset (VAR Mouse: resetRec); { 0 }πprocedure mShow; { 1 }πprocedure mHide; { 2 }πprocedure mPos (VAR Mouse: LocRec); { 3 }πprocedure mMoveto (col, row: Integer); { 4 }πprocedure mPressed (button: Integer; VAR Mouse: LocRec); { 5 }πprocedure mReleased (button: Integer; VAR Mouse: LocRec); { 6 }πprocedure mColRange (min, max : Integer); { 7 }πprocedure mRowRange (min, max : Integer); { 8 }πprocedure mGraphCursor (hHot, vHot: Integer; maskSeg, maskOfs: Word); { 9 }πprocedure mTextCursor (ctype, p1, p2: Word); { 10 }πprocedure mMotion (VAR moved: moveRec); { 11 }πprocedure mInstTask (mask: Word); { 12 }πprocedure mLpenOn; { 13 }πprocedure mLpenOff; { 14 }πprocedure mRatio (horiz, vert: Integer); { 15 }ππimplementationπvarπ maxcol : word absolute $0040:$004A; { x }ππprocedure EventHandler(Flags,CS,AX,BX,CX,DX,SI,DI,DS,ES,BP: Word);πinterrupt;πbeginπ mEvent.flag := AX;π mEvent.button := BX;π mEvent.col := CX;π mEvent.row := DX;π inLine($8B/$E5/$5D/$07/$1F/$5F/$5E/$5A/$59/$5B/$58/$CB);πend;ππfunction Lower (n1, n2: Integer): Integer;π beginπ if n1 < n2 then Lower := n1 else Lower := n2;π end;ππfunction Upper (n1, n2: Integer): Integer;π beginπ if n1 > n2 then Upper := n1 else Upper := n2;π end;ππprocedure mFixXY;π var i : integer;π beginπ if maxcol = 80π then i := 3π else i := 4;π mColRange(pred(x1) shl i,pred(x2) shl i);π mRowRange(pred(y1) shl 3,pred(y2) shl 3);π end;ππfunction mouseX;π var i : integer;π beginπ if maxcol = 80π then i := 3π else i := 4;π mouseX := succ(n shr i);π end;ππfunction mouseY;π beginπ mouseY := succ(n shr 3);π end;ππprocedure mReset (VAR Mouse: resetRec);π beginπ mreg.ax := 0;π intr(MDD, mreg);π Mouse.exists := boolean(mreg.ax <> 0);π Mouse.nButtons := mreg.bx;π end;ππprocedure mShow;π beginπ inline($B8/$01/$00/$CD/MDD);π{ mreg.ax := 1; }π{ intr(MDD, mreg); }π end;ππprocedure mHide;π beginπ inline($B8/$02/$00/$CD/MDD);π{ mreg.ax := 2; }π{ intr(MDD, mreg); }π end;ππprocedure mPos (VAR Mouse: LocRec);π beginπ mreg.ax := 3;π intr(MDD, mreg);π Mouse.buttonStatus := mreg.bx;π Mouse.column := mreg.cx;π Mouse.row := mreg.dx;π end;ππprocedure mMoveto (col, row: Integer);π var i : word;π beginπ if maxcol = 80π then i := 3π else i := 4;π mreg.ax := 4;π mreg.cx := col shl i;π mreg.dx := row shl i;;π intr(MDD, mreg);π end;ππprocedure mPressed (button: Integer; VAR Mouse: LocRec);π beginπ mreg.ax := 5;π mreg.bx := button;π intr(MDD, mreg);π Mouse.buttonStatus := mreg.ax;π Mouse.opCount := mreg.bx;π Mouse.column := mreg.cx;π Mouse.row := mreg.dx;π end;ππprocedure mReleased (button: Integer; VAR Mouse: LocRec);π beginπ mreg.ax := 6;π mreg.bx := button;π intr(MDD, mreg);π Mouse.buttonStatus := mreg.ax;π Mouse.opCount := mreg.bx;π Mouse.column := mreg.cx;π Mouse.row := mreg.dx;π end;ππprocedure mColRange (min, max : Integer);π beginπ mreg.ax := 7;π mreg.cx := Lower(min, max);π mreg.dx := Upper(min, max);π intr(MDD, mreg);π end;ππprocedure mRowRange (min, max : Integer);π beginπ mreg.ax := 8;π mreg.cx := Lower (min, max);π mreg.dx := Upper (min, max);π intr(MDD, mreg);π end;ππprocedure mGraphCursor (hHot, vHot: Integer; maskSeg, maskOfs: Word);π beginπ mreg.ax := 9;π mreg.bx := hHot;π mreg.cx := vHot;π mreg.dx := maskOfs;π mreg.es := maskSeg;π intr(MDD, mreg);π end;ππprocedure mTextCursor (ctype, p1, p2: Word);π beginπ mreg.ax := 10;π mreg.bx := ctype; { 0=software, 1=hardware }π mreg.cx := p1; { 0=and mask else start line }π mreg.dx := p2; { 0=xor mask else Cursor end line }π intr(MDD, mreg);π end;ππ{ Returns mouse displacement in mickeys since last call }πprocedure mMotion (VAR moved: moveRec);π beginπ mreg.ax := 11;π intr(MDD, mreg);π moved.hCount := mreg.cx;π moved.vCount := mreg.dx;π end;ππprocedure mInstTask;π beginπ mreg.ax := 12;π mreg.cx := mask; { see bit constants above }π mreg.dx := Ofs(EventHandler);π mreg.es := Seg(EventHandler);π intr(MDD, mreg);π end;ππprocedure mLpenOn;π beginπ mreg.ax := 13;π intr(MDD, mreg);π end;ππprocedure mLpenOff;π beginπ mreg.ax := 14;π intr(MDD, mreg);π end;ππprocedure mRatio (horiz, vert: Integer);π beginπ mreg.ax := 15;π mreg.cx := horiz;π mreg.dx := vert;π intr(MDD, mreg);π end;ππ{ Sample base line program...π mReset(theMouse);π if theMouse.existsπ then minstTask(15); (* for 80x25 *)π mFixXY(1,1,succ(lo(windmax)),succ(hi(windmax)));π mEvent.Flag := 0;π<< do the program >>π mReset(theMouse);π}πEND.ππ 5 08-17-9308:46ALL SWAG SUPPORT TEAM A Compelte Mouse Unit IMPORT 27 l╚ UNIT Mouse;ππ{Program: Master Mouse Routine Library}ππINTERFACEππUSES DOS;ππCONSTππ {Button press definitions}ππ PrL = 1;π PrR = 2;π PrLr = 3;π PrM = 4;π PrLM = 5;π PrMR = 6;π PrAll = 7;π PrNone = 0;ππ {Button definitions}ππ ButtonLeft = 0;π ButtonRight = 1;π ButtonMiddle = 2;πππFUNCTION ThereIsAMouse: Boolean;πFUNCTION MouseReset: Boolean;πFUNCTION GetMouseStatusπ (VAR MPosX, MPosY: Byte): Byte;ππPROCEDURE ClearButton (Button: Byte);πPROCEDURE MouseOn;πPROCEDURE MouseOff;πPROCEDURE SetMouseSoftCursorπ (MouseChar, MouseFGColor, MouseBGColor: Byte);ππIMPLEMENTATIONππCONSTπ MouseIntr = $33;ππVARπ MouseVisible : Boolean;π MHMax, MVMax, MHCell, MVCell : Word;π Regs : Registers;ππPROCEDURE MouseHandler (A, B, C, D: Byte);π BEGINπ WITH Regs DOπ BEGINπ ax := A;π bx := B;π cx := C;π dx := D;π Intr(MouseIntr, Regs)π ENDπ END;ππFUNCTION GetButtonUpStatusπ (Button: Byte;VAR MPosX, MPosY: Word): Boolean;ππ BEGINπ WITH Regs DOπ BEGINπ ax := 6;π bx := Button;π MouseHandler(ax, bx, 0, 0);π MPosX := cx DIV MHCell + 1;π MPosY := dx DIV MVCell + 1;π IF ax = 0 THENπ GetButtonUpStatus := TRUEπ ELSEπ GetButtonUpStatus := FALSEπ ENDπ END;ππPROCEDURE ClearButton (Button: Byte);πVARπ MPosX,MPosY: Word;ππ BEGINπ REPEAT UNTILπ GetButtonUpStatus(Button, MPosX,MPosY)π END;ππFUNCTION GetMouseStatusπ (VAR MPosX, MPosY: Byte): Byte;π BEGINπ WITH Regs DOπ BEGINπ ax := 3;π MouseHandler(ax, 0, 0, 0);π GetMouseStatus := bx;π MPosX := cx DIV MHCell + 1;π MPosY := dx DIV MVCell + 1π ENDπ END;ππPROCEDURE MouseOff;π BEGINπ IF MouseVisible THENπ BEGINπ MouseHandler(2, 0, 0, 0);π MouseVisible := FALSEπ ENDπ END;ππPROCEDURE MouseOn;π BEGINπ IF NOT MouseVisible THENπ BEGINπ MouseHandler(1, 0, 0, 0);π MouseVisible := TRUEπ ENDπ END;ππFUNCTION MouseReset: Boolean;π BEGINπ MHMax := 639; {Max virtual horizontal pos}π MVMax := 199; {Max virtual vertical pos}π MHCell := 8; {Mouse horizontal cell width}π MVCell := 8; {Mouse vertical cell height}π MouseHandler(0, 0, 0, 0);π IF Regs.ax = 0 THENπ MouseReset := FALSEπ ELSEπ MouseReset := TRUE;π MouseVisible := FALSEπ END;ππPROCEDURE SetMouseSoftCursorπ (MouseChar, MouseFGColor, MouseBGColor: Byte);π BEGINπ MouseOn;π Regs.ax := 10;π Regs.bx := 0; {Select software cursor}π {Screen Mask Value (don't change character)}π Regs.cx := $8800;π Regs.dx := $8800 + MouseBGColor * 4096 +π MouseFGColor * 256 + MouseChar;π Intr($33,Regs);π MouseOffπ END;ππFUNCTION ThereIsAMouse: Boolean;πCONSTπ IRET = 207;πVARπ MouseSegment : Word ABSOLUTE $0000:$00CE;π MouseOffset : Word ABSOLUTE $0000:$00CC;π MouseInstruction: Byte;π BEGINπ IF (MouseSegment = 0) ANDπ (MouseOffset = 0) THENπ ThereIsAMouse := FALSEπ ELSEπ BEGINπ MouseInstruction :=π MEM[MouseSegment:MouseOffset];π IF MouseInstruction = IRET THENπ ThereIsAMouse := FALSEπ ELSEπ ThereIsAMouse := TRUEπ ENDπ END;ππ{No initialization section}ππEND.π 6 08-27-9321:38ALL RAPHAEL VANNEY Set Mouse Cursor IMPORT 7 l╚ {πRAPHAEL VANNEYππ> Can anybody help me out on the Function INT 33 - 9/8. It's the set mouseπ> cursor Function. I see that you can draw your own mouse cursor, but I don'tπ> understand how to move a bitmap into Es:Dx. I don't know the size forπ> the bit map to be, or the dimensions. Could anybody help me out?π}ππConst Disque : Array [0..31] of Word =π (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,π 0,32766,32766,32760,32760,32766,32382,31806,π 31806,32382,32766,32382,32382,32382,32766,0);ππProcedure CurseurSouris(Var Motif; x, y : Word); Assembler;πAsmπ Mov AX, 9 { set cursor shape }π Mov BX, xπ Mov CX, yπ LES DX, Motifπ Int $33πend ;ππbeginπ { ... }π CurseurSouris(Disque, 8, 8);π { ... }πend.π 7 08-27-9321:38ALL MIKE BURNS The easy Mouse unit IMPORT 7 l╚ {πMIKE BURNSππ> How did you get a mouse Pointer into your Program?π}πππProcedure Clear_Regs;πbeginπ FillChar(Regs, SizeOf(Regs), 0);πend;πππFunction InitMouse : Boolean;πbeginπ Clear_Regs;ππ Regs.AX := 00;π Intr ($33, Regs);π if Regs.AX <> 0 then { if not 0 then YES THERE IS A MOUSE }π beginπ InitMouse := True;π MbutS := BX; { Number of buttons on the mouse }π endπ elseπ beginπ InitMouse := False;π Mbuts := 0;π end;πend;πππProcedure ShowMouse;π beginπ Clear_Regs;π Regs.AX := 01;π Intr ($33, Regs);πend;ππProcedure HideMouse;π beginπ Clear_Regs;π Regs.AX := 02;π Intr ($33, Regs);πend;π 8 11-21-9309:42ALL FRED JOHNSON Mouse Tutor SWAG9311 38 l╚ {πFrom: FRED JOHNSONπSubj: Mousey Control..πCan someone out there please explain how to read from the mouse?π}ππ{Explanation below in reference table}πUSES dos,crt;ππVARπ M1,M2,M3,M4 : word;π Regs : Registers; { MS DOS Registers }π satisfied : boolean; { if mouse pos and button are together }ππPROCEDURE mouse( var M1,M2,M3,M4 : word );π beginπ With Regs DOπ beginπ AX := M1; BX := M2; CX := M3; DX := M4;π end;π intr($33,Regs); { Interrupt $33, the mouse interrupt }π With Regs DOπ beginπ M1 := AX; M2 := BX; M3 := CX; M4 := DX;π end;π end;ππPROCEDURE initmouse;π beginπ M1 := 1 ; Mouse( M1,M2,M3,M4 ) { Set mouse cursor ON }π end;ππBEGINπ satisfied := false;π textcolor(7); { Grey }π clrscr;π initmouse;π while not keypressed do { until KEYBOARD key is pressed }π beginπ M1 := 3;π MOUSE(m1,M2,M3,M4);π IF (M2 and 1) <> 0 thenπ begin { if left button pressed }π writeln(' Left Button');π write(' M3 =',M3 div 8); write(' M4 =',M4 div 8);π end;π if (M2 and 2) <> 0 thenπ begin { if rght button pressed }π writeln(' Right Button');π write(' M3 =',M3 div 8); write(' M4 =',M4 div 8);π end;π if (M2 and 4) <> 0 then {if midlbutton pressed}π beginπ M1 := 4; M2 := 0; M3 := 30*8; M4 := 11*8; {Sets MCursor out of }π mouse( M1,M2,M3,M4 ); {the way }π gotoxy(25,10); write('***************');π gotoxy(25,11); write('* ');textcolor(14);π write('C'); textcolor(07); write('learscreen *');π gotoxy(25,12); write('* '); textcolor(14);π write('Q'); textcolor(07); write('uit *');π gotoxy(25,13); write('***************');π repeatπ M1 := 3;π mouse(M1,M2,M3,M4);π if (M3 div 8) = 26 then { Tests X position }π if (M4 div 8) = 10 then { Tests Y position }π if (M2 and 1) <> 0 then { Tests lft button }π beginπ satisfied := true;π M1 := 4; M2 := 0; M3 :=0; M4 :=0;{MCursor out of way}π mouse( M1,M2,M3,M4 );π clrscr;π end;ππ if (M3 div 8) = 26 then { Tests X position }π if (M4 div 8) = 11 then { Tests Y position }π if (M2 and 1) <> 0 then { Tests lft button }π beginπ satisfied := true;π M1 := 0; M2 :=0; M3 :=0; M4 := 0; { Turn Mouse Off }π mouse( M1,M2,M3,M4 );π clrscr;π halt;π end;ππ until satisfied = true;π clrscr;π end;π satisfied := false;π end;π M1 := 0; { Turn Mouse Off }π mouse(M1,M2,M3,M4);πEND.ππReference Tableπ M1 M2 M3 M4π 1 0 0 0 = Turn Mouse on with cursor.π 2 0 0 0 = Turn Mouse Off.π 3 ? ? ? = To see if buttons are pressed.π Test registers with logical AND (M2 is BX register)π M2 and 1 = Left Buttonπ M2 and 2 = Right Buttonπ M2 and 3 = Left and Right Buttonsπ M2 and 4 = Middle Buttonπ M2 and 5 = Left and Middle Buttonsπ M2 and 6 = Right and Middle Buttonsπ M2 and 7 = Left, Middle and Right Buttonsππ 3 0 X Y = Get Mouse Cursor position.π M3 (CX) will return Mouse X coordinates. (0 =left wall)π M4 (DX) will return Mouse Y coordinates. (632= rght wall)π Divide by 8 and add 1 for Turbo Pascal XY position.ππ 4 0 X Y = Set Mouse Cursor position.π M3 (CX) set for Mouse X coordinate. (0 = left wall)π M4 (DX) set for Mouse Y coordinate. (632= rght wall)ππ 6 ? 0 0 = Mouse Button Release Status. M2(BX)set if Trueππ Assembly Language Exampleπmov ax,0001 ; (M1 := 1)πint 33h ; Set Mouse cursor ONπhere: ;πmov ax,0003 ; (M1 := 3)πint 33h ; Test for mouse Keypressπand bx,1 ; left button?πjne lft ;πmov ax,0003 ;πint 33h ;πand bx,2 ; right button?πjne rht ;πmov ax,0003 ;πint 33h ;πand bx,4 ; middle button?πjne mid ;πjmp here ; if not keep loopingπlft: ;πmov dx,lft_st ; address of string if left buttonπjmp prnt ;πrht: ;πmov dx,rht_st ; address of string if right buttonπ 9 10-28-9311:25ALL GAYLE DAIVS A GOOD Mouse Unit SWAG9311 26 l╚ πUNIT AMOUSE; (* mouse/keyboard Routines *)ππINTERFACEππCONSTπ MouseInstalled : Boolean = FALSE;ππFUNCTION InitMouse : WORD;πPROCEDURE ShowMouseCursor;πPROCEDURE HideMouseCursor;πPROCEDURE SetMouseWindow (X1, Y1, X2, Y2 : WORD);πPROCEDURE GetMousePos (VAR X, Y, button : WORD);πPROCEDURE SetMousePos (X, Y : WORD);πPROCEDURE GetButtonPressInfo (VAR X, Y, Button, NumberOfPresses : WORD);πPROCEDURE GetButtonRelInfo (VAR X, Y, Button, NumberOfReleases : WORD);πPROCEDURE KeyOrButton (VAR Code, X, Y, Button : WORD; VAR Ch : CHAR);πFUNCTION KEYPRESSED : BOOLEAN;πFUNCTION MousePRESSED : BOOLEAN;πFUNCTION MouseORKeyPRESSED : BOOLEAN;ππIMPLEMENTATIONππUSES DOS;ππCONSTππ MIO = $33; (* Mouse Services *)π KBIO = $16; (* BIOS Keyboard *)ππVARπ X, Y : WORD;π reg : REGISTERS;πππFUNCTION KEYPRESSED : BOOLEAN; Assembler;πASMπ PUSH DSπ MOV AX, 40hπ MOV DS, AXπ CLIπ MOV AX, [1Ah]π CMP AX, [1Ch]π STIπ MOV AX, 0π JZ @NoPressπ INC AXπ @NoPress :π POP DSπEND;πππFUNCTION PollKey (VAR Status : WORD) : WORD;πVAR s : WORD;πBEGINπ asmπ MOV AH, 01π INT KBIOπ MOV @Result, AXπ LAHFπ AND AX, 64π MOV S, AXπ END;π Status := s;πEND;ππFUNCTION MousePressed : BOOLEAN;πVAR B : WORD;π BEGINπ Asmπ MOV AX, $0003π INT $33π MOV B, BXπ END;π MousePressed := (B <> 0);π END;ππFUNCTION MouseORKeyPressed : BOOLEAN;πVAR B : WORD;π BEGINπ Asmπ MOV AX, $0003π INT $33π MOV B, BXπ END;π MouseORKeyPressed := (B <> 0) OR KeyPressed;π END;ππPROCEDURE KeyOrButton (VAR Code, X, Y, Button : WORD; VAR Ch : CHAR);π (* wait for key or mouse click and returns data *)πVAR Status : WORD;πBEGINπ REPEATπ Code := PollKey (Status);π GetMousePos (X, Y, Button);π UNTIL (Button <> 0) OR (Status = 0);ππ IF (LO (Status) = 0) AND (HI (Status) <> 0) THENπ Ch := CHR ( HI (Status) + 128 )π ELSEπ Ch := CHR (LO (Status) );πEND;ππFUNCTION InitMouse : WORD;πBEGINπ Asmπ MOV AX, $0000π INT MIOπ MOV @Result, AXπ END;πEND;ππPROCEDURE ShowMouseCursor; Assembler;πAsmπ MOV AX, $0001π INT MIOπEND;ππPROCEDURE HideMouseCursor; Assembler;πAsmπ MOV AX, $0002π INT MIOπEND;ππPROCEDURE GetMousePos (VAR X, Y, Button : WORD);πVAR X1, Y1, b : WORD;πBEGINπ Asmπ MOV AX, $0003π INT MIOπ MOV b, BXπ MOV X1, CXπ MOV Y1, DXπ END;π X := X1;π Y := Y1;π Button := b;πEND;ππPROCEDURE SetMousePos (X, Y : WORD); Assembler;πAsmπ MOV AX, $0004π MOV CX, Xπ MOV DX, Yπ INT MIOπEND;ππPROCEDURE GetButtonPressInfo (VAR X, Y, Button, NumberOfPresses : WORD);πBEGINπ reg. AX := $0005;π reg. BX := Button;π INTR (MIO, reg);π Button := reg. AX;π X := reg. CX;π Y := reg. DX;π NumberOfPresses := reg. BXπEND;ππPROCEDURE GetButtonRelInfo (VAR X, Y, Button, NumberOfReleases : WORD);πBEGINπ reg. AX := $0006;π reg. BX := Button;π INTR (MIO, reg);π Button := reg. AX;π X := reg. CX;π Y := reg. DX;π NumberOfReleases := reg. BXπEND;ππPROCEDURE SetMouseWindow (X1, Y1, X2, Y2 : WORD);πBEGINπ reg. AX := $0007;π reg. CX := X1;π reg. DX := X2;π INTR ($33, reg);π INC (reg. AX, 1);π reg. CX := Y1;π reg. DX := Y2;π INTR (MIO, reg)πEND;ππBEGINπ MouseInstalled := (InitMouse <> 0);πEND. 10 11-02-9317:39ALL LOU DUCHEZ Mouse Library SWAG9311 49 l╚ {πFrom: LOU DUCHEZπSubj: mouse Libraryπ}ππunit mouse;πinterface { "Global" declarations }πvar mouseexist, mousecursoron: boolean; { Is a mouse hooked up? / Is the }πprocedure mouseinit; { mouse cursor "on"? }πprocedure mouseon;πprocedure mouseoff;πfunction mousex: word; { Note about coordinates: these }πfunction mousey: word; { routines return values starting }πfunction mouseleft: boolean; { at 0, not 1 (even in text mode). }πfunction mousemiddle: boolean; { So for text mode, you may want }πfunction mouseright: boolean; { to modify a bit ... }πprocedure setmousexy(newx, newy: word);πprocedure limitmouse(lox, loy, hix, hiy: word);πππimplementation { internal workings }πuses dos;πvar regs: registers; { Used for the "mouse" interrupts }π xshift, yshift: byte; { Depending on your video mode, you }π { may need to convert "mouse" }π { coordinates to / from "video" }πprocedure calcshifts; { coordinates. It's a matter of }πvar tempregs: registers; { shifting left/right; xshift }πbegin { records how to shift the "X", }π tempregs.ah := $0f; { and yshift records for the "Y". }π intr($10, tempregs); { Procedure CalcShifts figures out }π case tempregs.al of { what text mode you're in and how }π 0, 1, 2, 3, 7: begin { much to shift by. It gets the }π xshift := 3; { video mode w/interrupt $10/$0f; }π yshift := 3; { modes 0, 1, 2, 3 and 7 are text }π end; { modes. 4, 5, $0d and $13 are }π 4, 5, $0d, $13: begin { 320 x 200 graphics modes. All }π xshift := 1; { other graphics modes are okay }π yshift := 0; { "as is", although come to think }π end; { of it I had a CGA system when I }π else begin { wrote this library and thus }π xshift := 0; { couldn't text VGA modes ... }π yshift := 0;π end;π end;π end;πππprocedure mouseinit; { Initializes mouse -- determines if }πbegin { one is present, then figures out the }π regs.ax := $0000; { shifts, and initializes the "cursor" }π intr($33, regs); { variable to "false". }π mouseexist := (regs.ax = $FFFF);π if mouseexist then calcshifts; { Called automatically on startup; you }π mousecursoron := false; { should call it if you change video }π end; { modes in the program. }πππprocedure mouseon; { Turns cursor ON. }πbeginπ if mouseexist then begin { Note: you really should "pair" each }π regs.ax := $0001; { "on" with an "off"; if you don't, }π intr($33, regs); { the PC can get confused. }π mousecursoron := true;π end;π end;πππprocedure mouseoff; { Turns cursor OFF. Note: when writing }πbegin { to the screen, you typically want to }π if mouseexist then begin { turn the cursor OFF: the PC isn't }π regs.ax := $0002; { smart enough to say, "I'm writing a }π intr($33, regs); { character right where the mouse }π mousecursoron := false; { cursor is: better make it inverse }π end; { video". So you need to shut it off. }π end;πππfunction mousex: word; { Gets the current mouse column. }πvar tempword: word;πbeginπ if mouseexist then beginπ regs.ax := $0003;π intr($33, regs);π tempword := regs.cx;π endπ elseπ tempword := 0;π mousex := tempword shr xshift; { one of those funky "shift" things }π end;ππfunction mousey: word; { Gets the current mouse row. }πvar tempword: word;πbeginπ if mouseexist then beginπ regs.ax := $0003;π intr($33, regs);π tempword := regs.dx;π endπ elseπ tempword := 0;π mousey := tempword shr yshift;π end;πππfunction mouseleft: boolean; { Is the left button down? }πvar tempword: word;πbeginπ if mouseexist then beginπ regs.ax := $0003;π intr($33, regs);π tempword := regs.bx;π endπ elseπ tempword := 0;π mouseleft := mouseexist and (1 and tempword = 1);π end;πππfunction mousemiddle: boolean; { Is the middle button down? }πvar tempword: word;πbeginπ if mouseexist then beginπ regs.ax := $0003;π intr($33, regs);π tempword := regs.bx;π endπ elseπ tempword := 0;π mousemiddle := mouseexist and (4 and tempword = 4);π end;πππfunction mouseright: boolean; { Is the right button down? }πvar tempword: word;πbeginπ if mouseexist then beginπ regs.ax := $0003;π intr($33, regs);π tempword := regs.bx;π endπ elseπ tempword := 0;π mouseright := mouseexist and (2 and tempword = 2);π end;πππprocedure setmousexy(newx, newy: word); { Position mouse cursor. }πbeginπ regs.ax := $0004;π regs.cx := newx shl xshift; { Shifts to get it into "mouse" }π regs.dx := newy shl yshift; { coordinates. }π intr($33, regs);π end;πππprocedure limitmouse(lox, loy, hix, hiy: word); { Restrict mouse movements. }πbeginπ regs.ah := $0f;π intr($10, regs);π regs.ax := $0007;π regs.cx := lox shl xshift;π regs.dx := hix shl xshift;π intr($33, regs);π regs.ax := $0008;π regs.cx := loy shl yshift;π regs.dx := hiy shl yshift;π intr($33, regs);π end;πππbegin { Startup code: initializes mouse and gets video mode. }π mouseinit;π end.π 11 09-26-9309:18ALL RICHARD SADOWSKY The "Classic" mouse unit SWAG9311 38 l╚ Unit Mouse4;ππ{*******************************************************************}π{* Mouse4 - Text Mouse Unit *}π{* version .9, 11/20/87 *}π{* by Richard Sadowsky 74017,1670 *}π{* released to the public domain *}π{*******************************************************************}ππInterfaceππUses DOS;ππconstπ CURPOS = 1; { not used yet in this version }π LEFTPRESS = 2;π LEFTREL = 4;π RIGHTPRESS = 8;π RIGHTREL = 16;ππvarπ Mouse_Reg : Registers;π Mouse_Installed : Boolean;π Mouse_Error : Word;ππfunction InitMouse : Word;π{ Function 0 - Initialize mouse software and hardware }ππprocedure ShowMouse;π{ function 1 - show mouse cursor }ππprocedure HideMouse;π{ function 2 - hide mouse cursor }ππfunction MousePosition(var MouseX,MouseY : Word) : Word;π{ function 3 - return mouse position and button status }π{ X and Y values scaled for 80 col text mode }ππprocedure setmouseposition(mousex, mousey: Word);π{ function 4 - sets mouse position }π{ X and Y values scaled for 80 col text mode }ππfunction mousepress(button: Word;π var count, lastx, lasty: Word): Word;π{ function 5 - gets button press information }π{ X and Y values scaled for 80 col text mode }ππfunction mouserelease(button: Word;π var count, lastx, lasty: Word): Word;π{ function 6 - gets button release information }π{ X and Y values scaled for 80 col text mode }ππprocedure setmousexy(x1,y1,x2,y2: Word);π{ functions 7 and 8 - sets min/max values for horizontal/vertical }π{ X and Y values scaled for 80 col text mode }ππprocedure restoremousexy;π{ functions 7 and 8 - restores min/max values for CGA screen }ππprocedure SetPixeltoMickey(Horiz,Verti : Word);π{ function 15 - sets the mickey to pixel ratio }ππimplementationππfunction InitMouse : Word;π{ Function 0 - Initialize mouse software and hardware }πbeginπ with Mouse_Reg doπ Ax := 0;π Intr($33,Mouse_Reg);π InitMouse := Mouse_Reg.Ax;πend;ππprocedure ShowMouse;π{ function 1 - show mouse cursor }πbeginπ Mouse_Reg.Ax := 1;π Intr($33,Mouse_Reg);πend;ππprocedure HideMouse;π{ function 2 - hide mouse cursor }ππbeginπ Mouse_Reg.AX := 2;π Intr($33,Mouse_Reg);πend;ππfunction MousePosition(var MouseX,MouseY : Word) : Word;π{ function 3 - return mouse position and button status }π{ X and Y values scaled for 80 col text mode }πbeginπ Mouse_Reg.Ax := 3;π Intr($33,Mouse_Reg);π with Mouse_Reg do beginπ MouseX := Succ(Cx DIV 8);π MouseY := Succ(Dx DIV 8);π MousePosition := Bx;π end;πend;ππprocedure setmouseposition(mousex, mousey: Word);π{ function 4 - sets mouse position }π{ X and Y values scaled for 80 col text mode }πbeginπ Mouse_Reg.ax:=4;π Mouse_Reg.cx:=Pred(mousex*8);π Mouse_Reg.dx:=Pred(mousey*8);π intr($33,Mouse_Reg);πend;ππfunction mousepress(button: Word;π var count, lastx, lasty: Word): Word;π{ function 5 - gets button press information }π{ X and Y values scaled for 80 col text mode }πbeginπ Mouse_Reg.ax:=5;π Mouse_Reg.bx:=button;π intr($33,Mouse_Reg);;π mousepress:=Mouse_Reg.ax;π count:=Mouse_Reg.bx;π lastx:=Succ(Mouse_Reg.cx div 8);π lasty:=Succ(Mouse_Reg.dx div 8);πend;ππfunction mouserelease(button: Word;π var count, lastx, lasty: Word): Word;π{ function 6 - gets button release information }π{ X and Y values scaled for 80 col text mode }πbeginπ Mouse_Reg.ax:=6;π Mouse_Reg.bx:=button;π intr($33,Mouse_Reg);;π mouserelease:=Mouse_Reg.ax;π count:=Mouse_Reg.bx;π lastx := Succ(Mouse_Reg.cx div 8);π lasty := Succ(Mouse_Reg.dx div 8);πend;ππprocedure setmousexy(x1,y1,x2,y2: Word);π{ functions 7 and 8 - sets min/max values for horizontal/vertical }π{ X and Y values scaled for 80 col text mode }πbeginπ Mouse_Reg.ax:=7;π Mouse_Reg.cx:=Pred(x1*8);π Mouse_Reg.dx:=Pred(x2*8);π intr($33,Mouse_Reg);π Mouse_Reg.ax:=8;π Mouse_Reg.cx:=Pred(y1*8);π Mouse_Reg.dx:=Pred(y2*8);π intr($33,Mouse_Reg);πend;ππprocedure restoremousexy;π{ functions 7 and 8 - restores min/max values for CGA screen }πbeginπ Mouse_Reg.ax:=7;π Mouse_Reg.cx:=0;π Mouse_Reg.dx:=639;π intr($33,Mouse_Reg);π Mouse_Reg.ax:=8;π Mouse_Reg.cx:=0;π Mouse_Reg.dx:=199;π intr($33,Mouse_Reg);πend;ππprocedure SetPixeltoMickey(Horiz,Verti : Word);π{ function 15 - sets the mickey to pixel ratio }ππbeginπ with Mouse_Reg do beginπ Ax := 15;π Cx := Horiz;π Dx := Verti;π end;π Intr($33,Mouse_Reg)πend;ππbeginπ Mouse_Error := InitMouse;π Mouse_Installed := Mouse_Error = 65535;πend.π 12 11-26-9317:15ALL SWAG SUPPORT TEAM Rodent Control SWAG9311 129 l╚ UNIT Mouse;π{*****************************************************************************}π INTERFACEπ{*****************************************************************************}πUSES DOS;ππTYPE mouse_cursor_mask = RECORDπ screen_mask : ARRAY[0..7] OF BYTE;π cursor_mask : ARRAY[8..15] OF BYTE;π END;ππCONST on = TRUE;πCONST off = FALSE;πCONST left = $00;πCONST right = $01;ππCONST change_in_cursor_position = $0001; {call masks for user defined}πCONST left_button_pressed = $0002; {input mask and swap vectors}πCONST left_button_released = $0004;πCONST right_button_pressed = $0008;πCONST right_button_released = $0010;ππCONST alternate_key_pressed = $0001; {call masks for alternate user handlers}πCONST control_key_pressed = $0002;πCONST shift_button_pressed = $0004;πCONST right_button_up = $0008;πCONST right_button_down = $0010;πCONST left_button_up = $0020;πCONST left_button_down = $0040;πCONST cursor_moved = $0080;ππVAR mouse_driver_disabled : BOOLEAN;πVAR number_of_presses, number_of_releases : INTEGER;πVAR number_buttons, x, y : INTEGER;πVAR button_status, horizontal_counts, vertical_counts : INTEGER;πVAR left_mouse_button_pressed, right_mouse_button_pressed,π left_mouse_button_released, right_mouse_button_released : BOOLEAN;πVAR register : REGISTERS;ππPROCEDURE check_button_status;πPROCEDURE disable_mouse_driver (VAR int33h_vector_address : POINTER);πPROCEDURE enable_mouse_driver; INLINE($B8/$20/$00/$CD/$33);πFUNCTION get_alternate_user_interrupt_vector (call_mask : WORD) : POINTER;πPROCEDURE get_left_button_press_information;πPROCEDURE get_left_button_release_information;πPROCEDURE get_mouse_position;πPROCEDURE get_mouse_sensitivity (VAR horizontal_coordinates_per_pixel,π vertical_coordinates_per_pixel,π double_speed_threshold : WORD);πPROCEDURE get_right_button_press_information;πPROCEDURE get_right_button_release_information;πPROCEDURE light_pen_emulation; INLINE($B8/$0D/$00/$CD/$33);πFUNCTION mouse_button_pressed : BOOLEAN;πPROCEDURE mouse_cursor_off; INLINE($B8/$02/$00/$CD/$33);πPROCEDURE mouse_cursor_off_area (x1,y1,x2,y2 : INTEGER);πPROCEDURE mouse_cursor_on; INLINE($B8/$01/$00/$CD/$33);πFUNCTION mouse_exists : BOOLEAN;πFUNCTION mouse_state_buffer_size : INTEGER;πFUNCTION mouse_video_page : WORD;πFUNCTION number_of_buttons : INTEGER;πPROCEDURE relative_number_of_screen_positions_moved (VAR x, y : INTEGER);π {reported in units of 0.02 inches - approximately 0.5 millimeters}πPROCEDURE reset_mouse_software; INLINE($B8/$21/$00/$CD/$33);πPROCEDURE restore_mouse_driver_state (mouse_state_buffer_segment,π mouse_state_buffer_offset : WORD);π {use when returning from another program to your program}πPROCEDURE save_mouse_driver_state (mouse_state_buffer_segment,π mouse_state_buffer_offset : WORD);π {use mouse_state_buffer_size to set up buffer first;π use when EXEC another program from your program}πPROCEDURE set_alternate_mouse_user_handler (call_mask,π function_offset : INTEGER);πPROCEDURE set_double_speed_threshold (threshold_speed : INTEGER);πPROCEDURE set_graphics_mouse_cursor (hot_spot_x, hot_spot_y : INTEGER;π screen_and_cursor_mask : mouse_cursor_mask);πPROCEDURE set_mouse_physical_movement_ratio (x8_positions_to_move,π y8_positions_to_move : INTEGER);π {each position corresponds to 1/200th of an inch}πPROCEDURE set_mouse_position (x,y : INTEGER);πPROCEDURE set_mouse_sensitivity (horizontal_coordinates_per_pixel,π vertical_coordinates_per_pixel,π double_speed_threshold : WORD);πPROCEDURE set_mouse_video_page (page_number : WORD);πPROCEDURE set_mouse_x_bounds (minimum_x, maximum_x : WORD);πPROCEDURE set_mouse_y_bounds (minimum_y, maximum_y : WORD);πPROCEDURE set_text_mouse_attribute_cursor (screen_cursor_mask_offset : WORD);πPROCEDURE set_text_mouse_hardware_cursor (top_scan_line,π bottom_scan_line : INTEGER);πPROCEDURE stop_light_pen_emulation; INLINE($B8/$0E/$00/$CD/$33);πPROCEDURE swap_mouse_interrupt_vector (VAR call_mask, mouse_vector_segment,π mouse_vector_offset : WORD);π{*****************************************************************************}π IMPLEMENTATIONπ{*****************************************************************************}πPROCEDURE check_button_status;π VAR check_left, check_right : WORD;π BEGINπ IF button_status AND $0001 = $0001 THENπ left_mouse_button_pressed := TRUE ELSEπ left_mouse_button_pressed := FALSE;ππ IF button_status AND $0002 = $0002 THENπ right_mouse_button_pressed := TRUE ELSEπ right_mouse_button_pressed := FALSE;π END;π{*****************************************************************************}πPROCEDURE disable_mouse_driver (VAR int33h_vector_address : POINTER);π BEGINπ register.AX := $001F;π INTR($33,register);π IF register.AX = $001F THENπ BEGINπ mouse_driver_disabled := TRUE;π int33h_vector_address := PTR(register.ES,register.BX);π END ELSE mouse_driver_disabled := FALSE;π END;π{*****************************************************************************}πFUNCTION get_alternate_user_interrupt_vector (call_mask : WORD) : POINTER;π BEGINπ register.AX := $0019;π register.CX := call_mask;π INTR($33,register);π get_alternate_user_interrupt_vector := PTR(register.BX,register.DX);π END;π{*****************************************************************************}πPROCEDURE get_left_button_press_information;π BEGINπ register.BX := $0000;π register.AX := $0005;π INTR($33,register);π number_of_presses := register.BX;π x := register.CX;π y := register.DX;π button_status := register.AX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE get_left_button_release_information;π BEGINπ register.BX := $0000;π register.AX := $0006;π INTR($33,register);π number_of_releases := register.BX;π x := register.CX;π y := register.DX;π button_status := register.AX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE get_mouse_position;π BEGINπ register.AX := $0003;π INTR($33,register);π x := register.CX;π y := register.DX;π button_status := register.BX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE get_mouse_sensitivity (VAR horizontal_coordinates_per_pixel,π vertical_coordinates_per_pixel,π double_speed_threshold : WORD);π BEGINπ register.AX := $001B;π register.BX := horizontal_coordinates_per_pixel;π register.CX := vertical_coordinates_per_pixel;π register.DX := double_speed_threshold;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE get_right_button_press_information;π BEGINπ register.BX := $0001;π register.AX := $0005;π INTR($33,register);π number_of_presses := register.BX;π x := register.CX;π y := register.DX;π button_status := register.AX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE get_right_button_release_information;π BEGINπ register.BX := $0001;π register.AX := $0006;π INTR($33,register);π number_of_releases := register.BX;π x := register.CX;π y := register.DX;π button_status := register.AX;π check_button_status;π END;π{*****************************************************************************}πFUNCTION mouse_button_pressed : BOOLEAN;π BEGINπ register.AX := $0003;π INTR($33,register);π button_status := register.BX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE mouse_cursor_off_area (x1,y1,x2,y2 : INTEGER);π BEGINπ register.AX := $0010;π register.CX := x1;π register.DX := y1;π register.SI := x2;π register.DI := y2;π INTR($33,register);π mouse_cursor_on; {may need to remove this statement}π END;π{*****************************************************************************}πFUNCTION mouse_exists : BOOLEAN;π BEGINπ register.AX := $0021;π INTR($33,register);π IF (register.AX = $FFFF) AND (register.BX = $02) THENπ mouse_exists := TRUE ELSEπ mouse_exists := FALSE;π END;π{*****************************************************************************}πFUNCTION mouse_state_buffer_size : INTEGER;π BEGINπ register.AX := $15;π INTR($33,register);π mouse_state_buffer_size := register.BX;π END;π{*****************************************************************************}πFUNCTION mouse_video_page : WORD;π BEGINπ INLINE($B8/$1E/$00/$CD/$33);π mouse_video_page := register.BX;π END;π{*****************************************************************************}πFUNCTION number_of_buttons : INTEGER;π BEGINπ register.AX := $0000;π INTR($33,register);π number_of_buttons := register.BX;π END;π{*****************************************************************************}πPROCEDURE relative_number_of_screen_positions_moved (VAR x, y : INTEGER);π BEGINπ register.AX := $000B;π INTR($33,register);π register.CX := x;π register.DX := y;π END;π{*****************************************************************************}πPROCEDURE restore_mouse_driver_state (mouse_state_buffer_segment,π mouse_state_buffer_offset : WORD);π BEGINπ register.AX := $17;π register.ES := mouse_state_buffer_segment;π register.DX := mouse_state_buffer_offset;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE save_mouse_driver_state (mouse_state_buffer_segment,π mouse_state_buffer_offset : WORD);π BEGINπ register.AX := $16;π register.ES := mouse_state_buffer_segment;π register.DX := mouse_state_buffer_offset;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_alternate_mouse_user_handler (call_mask,π function_offset : INTEGER);π BEGINπ register.AX := $0018;π register.CX := call_mask;π register.DX := function_offset;π INTR($33,register);π x := register.CX;π y := register.DX;π horizontal_counts := register.DI;π vertical_counts := register.SI;π button_status := register.BX;π check_button_status;π END;π{*****************************************************************************}πPROCEDURE set_mouse_video_page (page_number : WORD);π BEGINπ register.AX := $001D;π register.BX := page_number;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_double_speed_threshold (threshold_speed : INTEGER);π BEGINπ register.AX := $0013;π register.DX := threshold_speed;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_graphics_mouse_cursor (hot_spot_x, hot_spot_y : INTEGER;π screen_and_cursor_mask : mouse_cursor_mask);π BEGINπ register.AX := $0009;π register.BX := hot_spot_x;π register.CX := hot_spot_y;π register.ES := SEG(screen_and_cursor_mask);π register.DX := OFS(screen_and_cursor_mask);π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_mouse_physical_movement_ratio (x8_positions_to_move,π y8_positions_to_move : INTEGER);π BEGINπ register.AX := $000F;π register.CX := x8_positions_to_move;π register.DX := y8_positions_to_move;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_mouse_position (x,y : INTEGER);π BEGINπ register.AX := $0004;π register.CX := x;π register.DX := y;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_mouse_sensitivity (horizontal_coordinates_per_pixel,π vertical_coordinates_per_pixel,π double_speed_threshold : WORD);π BEGINπ register.AX := $001A;π register.BX := horizontal_coordinates_per_pixel;π register.CX := vertical_coordinates_per_pixel;π register.DX := double_speed_threshold;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_mouse_x_bounds (minimum_x, maximum_x : WORD);π BEGINπ register.AX := $0008;π register.CX := minimum_x;π register.DX := maximum_x;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_mouse_y_bounds (minimum_y, maximum_y : WORD);π BEGINπ register.AX := $0007;π register.CX := minimum_y;π register.DX := maximum_y;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_text_mouse_attribute_cursor (screen_cursor_mask_offset : WORD);π BEGINπ register.AX := $000A;π register.BX := $0000;π register.CX := screen_cursor_mask_offset;π register.DX := screen_cursor_mask_offset + 8;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_text_mouse_hardware_cursor (top_scan_line,π bottom_scan_line : INTEGER);π BEGINπ register.AX := $000A;π register.BX := $0001;π register.CX := top_scan_line;π register.DX := bottom_scan_line;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE set_user_defined_input_mask (call_mask, function_offset : INTEGER);π BEGINπ register.AX := $000C;π register.CX := call_mask;π register.DX := function_offset;π INTR($33,register);π END;π{*****************************************************************************}πPROCEDURE swap_mouse_interrupt_vector (VAR call_mask, mouse_vector_segment,π mouse_vector_offset : WORD);π VAR register_DS : INTEGER;π BEGINπ register_DS := register.DS; {save the data segment}π register.AX := $0014;π register.CX := call_mask;π register.ES := mouse_vector_offset;π register.DX := mouse_vector_offset;π INTR($33,register);π call_mask := register.CX;π mouse_vector_segment := register.ES;π mouse_vector_offset := register.DX;π register.DS := register_DS; {resets the data segment}π button_status := register.BX;π check_button_status;π horizontal_counts := register.DI;π vertical_counts := register.SI;π x := register.CX;π y := register.DX;π END;π{*****************************************************************************}πBEGINπ x := 0;π y := 0;π number_buttons := number_of_buttons;π number_of_presses := 0;π number_of_releases := 0;π left_mouse_button_released := FALSE;π right_mouse_button_released := FALSE;π left_mouse_button_released := FALSE;π right_mouse_button_released := FALSE;πEND.π